package com.nwpu.server.authserver.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.nwpu.server.authserver.entity.UserEntity;
import com.nwpu.server.authserver.exception.EmailException;
import com.nwpu.server.authserver.exception.UsernameException;
import com.nwpu.server.authserver.vo.LoginForm;
import com.nwpu.server.authserver.vo.PasswordForm;
import com.nwpu.server.authserver.vo.RegisterForm;
import com.nwpu.server.common.response.PageUtils;

import java.util.Map;

/**
 * 用户
 *
 * @author YuXingZh
 * @email 617058979@qq.com
 * @date 2022-03-13 16:29:47
 */
public interface UserService extends IService<UserEntity> {

    PageUtils queryPage(Map<String, Object> params);

    /**
     * 查询用户是否存在
     * @param username
     * @return
     */
    UserEntity queryByUserName(String username);

    /**
     * 修改密码
     * @param userId
     * @param password
     * @param newPassword
     * @return
     */
    boolean updatePassword(Long userId, String password, String newPassword);

    /**
     * 用户注册
     * @param vo
     */
    void register(RegisterForm vo);

    /**
     * 判断邮箱是否重复
     * @param email
     * @return
     */
    void checkEmailUnique(String email) throws EmailException;

    /**
     * 判断用户名是否重复
     * @param userName
     * @return
     */
    void checkUserNameUnique(String userName) throws UsernameException;

    /**
     * 用户登录
     * @param vo
     * @return
     */
    UserEntity login(LoginForm vo);
}

